<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.log(a);
        var a = 12;

        function fn() {
            console.log(a);
            var a = 13;
        }
        fn();
        console.log(a);
        /* 
            我的分析：
            首先定义变量使用var 关键字定义的,并且不是在严格模式下,所以有变量提升
            var a;
            function fn () {
                var a;
                 console.log(a); // undefined
                 a = 13;
            }
            console.log(a) // undefined
            a = 12;
            fn();
            console.log(a) // 12
            
         */
    </script>
</body>

</html>